#include "app_config.h"

#if APP_SELECT_EXAMPLE == 3

#include "polsys.h"

#define LED             AP_GPIO->ODR_f.ODR7
#define TURN_EN_PIN     P33_PA21
#define TURN_EN         AP_GPIO->IDR_f.IDR21


USED void GpioIRQHandler()
{
    if(Gpio_GetIntFlag(TURN_EN_PIN))
    {
        if(!TURN_EN)
        {
            gpio_int_param_t ip;

            ip.Enable = 1;
            ip.Mode = GPIO_IM_EDGE;
            ip.Polarity = GPIO_IP_POSITIVE;     // 下一次上升沿中断
            Gpio_SetInt(TURN_EN_PIN, &ip);

            LED = 1;
        }
        else
        {
            gpio_int_param_t ip;

            ip.Enable = 1;
            ip.Mode = GPIO_IM_EDGE;
            ip.Polarity = GPIO_IP_NEGATIVE;     // 下一次下降沿中断
            Gpio_SetInt(TURN_EN_PIN, &ip);

            LED = 0;
        }
    }
    Gpio_ClrIntFlags();
}


// 启动事件，程序启动时执行一次
void App_Load()
{
    gpio_int_param_t ip;

    Gpio_Init();

    ip.Enable = 1;
    ip.Mode = GPIO_IM_EDGE;
    ip.Polarity = GPIO_IP_NEGATIVE;
    Gpio_SetInt(TURN_EN_PIN, &ip);  // 配置文件中的中断相关初始参数被覆盖
}








#endif
